# 导入库
import cv2

# 读入图片，保存到变量image
image = cv2.imread("images/test.jpg")

# 显示图片
cv2.imshow("image", image)

# 复制图片到新的变量new_image
new_image = image.copy()

# 画出一个100*100的矩形
x = 10
y = 20
w = 100
h = 100
cv2.rectangle(new_image, (x, y), (x+w, y+h), (0, 255, 0), 2)

# 写字（opencv如果要写中文，必须特殊处理）
cv2.putText(new_image, text="Hello opencv", org=(x+w+10, y), fontFace=cv2.FONT_HERSHEY_SIMPLEX, fontScale=1,
            color=(255, 0, 0), thickness=2)

# 显示新的图像
cv2.imshow("new_image", new_image)

# 等待键盘按下
cv2.waitKey(0)

# 保存图片
# cv2.imwrite("images/results/test_new.jpg", new_image)
